<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>Yolo Admin</title>
    <link rel="stylesheet" type="text/css" href="/css/common.css" />
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
    <script> var yoloXsrfToken = '{{.XsrfToken}}'; </script>
    <script src="/scripts/yolo.js" type="text/javascript"></script>
  </head>
<body style="font-size:12px">

<h1>Yolo Admin</h1>

<div id="ajax-result" class="ajax-result hide">
  <p id="ajax-result-body"></p>
</div>

<div style="font-weight:bold; font-size:14px; line-height:18px;">
<a href="/admin/issues">Issues</a> |
<a href="/admin/users">Users</a> |
<a href="/admin/activities">Activities</a>
<br />
<a href="/admin/console/">Admin Console (dev_server only)</a>
</div>

<hr />
<p>
  <a href="#" onclick="yolo.postAjaxLink('/admin/buildbot_start_check')">buildbot_start_check</a> |
  <a href="/worker/buildbot_start_check">(worker)</a>
  <br />
  <a href="/buildbot_activity_data">buildbot_activity_data</a>
  <br />
  <a href="#" onclick="yolo.postAjaxLink('/admin/chromium_status_start_check')">chromium_status_start_check</a> |
  <a href="/worker/chromium_status_start_check">(worker) start</a> |
  <a href="/worker/chromium_status_store_action">(worker) store</a>
  <br />
  <a href="/admin/google_codesite_start_check">google_codesite_start_check</a> |
  <a href="/worker/google_codesite_start_check">(worker)</a>
</p>

<hr />
<h3>Purge Datastore</h3>

<form id="purge-datastore-form" action="#">
  <label>Kind:</label>
  <input id="kind" name="kind" size="40" type="text"></input>
  <input type="submit" value="Purge"></input>
</form>

<hr />
<h3>Memcache</h3>

<form id="manage-memcache-form" action="#">
  <label>Key:</label>
  <input id="memcache-key" size="100" type="text"></input>
  <br />
  <button id="memcache-get-counter">Get Counter Value</button>
  <button id="memcache-delete">Delete</button>
</form>

<hr />
<h3>Add New Poll Context</h3>
<form id="add-poll-form" action="#">
  <script>
    function handle_onchange_siteurl() {
      if (document.getElementById('siteurl').value == 'code.google.com') {
        document.getElementById('project-input').style.display = 'inline'
      } else {
        document.getElementById('project-input').style.display = 'none'
      }
    }
  </script>
  <label>Site URL:</label>
  <select id="siteurl" name="siteurl" onchange="handle_onchange_siteurl()">
    {{range .SupportedSites}}
    <option value="{{.}}">{{.}}</option>
    {{end}}
  </select>
  <span style="display:none" id="project-input">/p/<input type="text" id="project" name="project"></input></span>
  <br />

  <label>Mode</label>
  <input type="radio" name="poll_mode" id="mode_update" value="update" checked />Update
  <input type="radio" name="poll_mode" id="mode_backdate" value="backdate" />Backdate
  <br />

  <label>Modified after:</label> (YYYY-MM-DD)
  <input id="modified_after" type="date"></input><br />

  <label>Modified before:</label> (YYYY-MM-DD)
  <input id="modified_before" type="date" disabled></input><br />

  <label>Backdate time range (in minutes):</label>
  <input type="number" name="backdate_timerange" id="backdate_timerange" value="120" step="20" disabled></input>
  <br />

  <input type="reset" value="Clear"></input>
  <input type="submit" value="Add"></input>
</form>

<hr />

<h3>Poll Contexts</h3>

<a href="#" onclick="yolo.postAjaxLink('/admin/start_poll_all', 'start=1')">Start all</a> |
<a href="#" onclick="yolo.postAjaxLink('/admin/stop_poll_all')">Stop all</a> |
<a href="#" onclick="yolo.postAjaxLink('/admin/delete_poll_all')">Delete all</a>

<p>
{{range .PollContexts}}
<p>
<div>SiteURL: <a href="http://{SiteURL}/">{{.SiteURL}}</a></div>
<div>Created: {{date .Created}}</div>
<div>Modified after: {{date .ModifiedAfter}}</div>
<div>Modified before: {{date .ModifiedBefore}}</div>
<div>Mode: {{.Mode}} (1:Update, 2:Backdate)</div>
<div>Stopped: {{.Stopped}}</div>
<div>BackdateTimeRange: {{.BackdateTimeRange}}</div>
<div>Processed: {{.Processed}}</div>
<div>Key: {{.Key}}</div>
<div>
  <a href="#" onclick="yolo.postAjaxLink('/admin/start_poll', 'key={{.Key}}&start=1', true)">Start</a> |
  <a href="#" onclick="yolo.postAjaxLink('/admin/stop_poll', 'key={{.Key}}', true)">Stop</a> |
  <a href="#" onclick="yolo.postAjaxLink('/admin/delete_poll', 'key={{.Key}}', true)">Delete</a>
</div>
</p>
{{end}}
</p>

  <script src="/scripts/yolo-admin.js" type="text/javascript"></script>
</body>
</html>
